import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';

part 'property_model.g.dart';

@JsonSerializable(explicitToJson: true)
class PropertyResponseModel extends Equatable{
  final int resultCode;
  final List<PropertyModel> resultData;
  final String resultMsg;

  PropertyResponseModel({this.resultCode, this.resultData, this.resultMsg});
  factory PropertyResponseModel.fromJson(Map<String, dynamic> json) => _$PropertyResponseModelFromJson(json);
  Map<String, dynamic> toJson() => _$PropertyResponseModelToJson(this);

  @override
  List<Object> get props => [resultCode, resultData, resultMsg];
}

@JsonSerializable(explicitToJson: true)
class PropertyModel extends Equatable{
  final String attrId;
  final bool allowEdit;
  final String mandatory;
  final int orderValue;
  final String attrName;
  final String multiSelect;
  final List<OptionModel> options;
  final List<AttrNameModel> attrNames;

  PropertyModel(
      {this.attrId,
      this.allowEdit,
      this.mandatory,
      this.orderValue,
      this.attrName,
      this.multiSelect,
      this.options,
      this.attrNames});

  factory PropertyModel.fromJson(Map<String, dynamic> json) => _$PropertyModelFromJson(json);
  Map<String, dynamic> toJson() => _$PropertyModelToJson(this);
  @override
  List<Object> get props => [attrId, allowEdit, mandatory, orderValue, attrName, multiSelect, options, attrNames];
  
}

@JsonSerializable(explicitToJson: true)
class OptionModel extends Equatable{
  final String price;
  final bool allowEdit;
  final List<OptionNameModel> optionNames;
  final String optionId;
  final String optionName;
  final int orderValue;

  OptionModel(
      {this.price,
      this.allowEdit,
      this.optionNames,
      this.optionId,
      this.optionName,
      this.orderValue});

  factory OptionModel.fromJson(Map<String, dynamic> json) => _$OptionModelFromJson(json);
  Map<String, dynamic> toJson() => _$OptionModelToJson(this);

  @override
  List<Object> get props => [price, allowEdit, optionId, optionName, optionNames, orderValue];
}

@JsonSerializable(explicitToJson: true)
class OptionNameModel extends Equatable{
  final String name;
  final String language;

  OptionNameModel({this.name, this.language});

  factory OptionNameModel.fromJson(Map<String, dynamic> json) => _$OptionNameModelFromJson(json);
  Map<String, dynamic> toJson() => _$OptionNameModelToJson(this);
  @override
  List<Object> get props => [name, language];
}

@JsonSerializable(explicitToJson: true)
class AttrNameModel extends Equatable{
  final String name;
  final String language;

  AttrNameModel({this.name, this.language});
  
  factory AttrNameModel.fromJson(Map<String, dynamic> json) => _$AttrNameModelFromJson(json);
  Map<String, dynamic> toJson() => _$AttrNameModelToJson(this);
  @override
  List<Object> get props => [name, language];
}